<template>
  <div v-loading="loading">
    <card :width="1400" :top="24">
      <div class="container">
        <div class="title">教学统计</div>
        <div class="teach_statistics">
          <div class="teach_item" @click="toGradeList">
            <div class="teach_item_left">
              <img src="@/assets/images/statistics/evaluate_index.png" alt="加载失败"/>
            </div>
            <div class="teach_item_right">
              <div class="teach_item_right_label">成绩统计</div>
              <div class="teach_item_right_btn color_purole">立即查看</div>
            </div>
          </div>
          <div class="teach_item ml_48" @click="toTeachingQualityAnalysis">
            <div class="teach_item_left">
              <img src="@/assets/images/statistics/grade_index.png" alt="加载失败"/>
            </div>
            <div class="teach_item_right">
              <div class="teach_item_right_label">教学评价与质量分析</div>
              <div class="teach_item_right_btn color_blue">立即查看</div>
            </div>
          </div>
        </div>
        <div class="title mt_64">课程统计</div>
        <!--        <cameraCanvas></cameraCanvas>-->
        <div class="course_statistics">
          <div
            v-for="(item, index) in courseList"
            class="course_item"
            :style="{ backgroundImage: `url(${item.icon})` }"
            :key="index"
          >
            <div class="pd_num">
              <div class="course_item_label">
                {{ item.label }}
                <el-tooltip
                  v-if="item.id!=1"
                  content="正式版/草稿"
                  placement="top"
                  effect="dark"
                >
                  <i class="el-icon-question"></i>
                </el-tooltip>

              </div>
              <div class="course_item_value" v-if="item.id==1">
                {{ item.value }}
              </div>
              <div class="course_item_value" v-if="item.id!=1">
                {{ item.onlineValue }}/{{ item.value }}
              </div>
            </div>
          </div>
        </div>
        <div class="title mt_64">个人统计</div>
        <div class="course_statistics">
          <div
            v-for="(item, index) in personList"
            class="course_item"
            :style="{ backgroundImage: `url(${item.icon})` }"
            :key="index"
          >
            <div class="pd_num">
              <div class="course_item_label">
                {{ item.label }}
              </div>
              <div class="course_item_value">
                {{ item.value }}
              </div>
            </div>
          </div>
        </div>
      </div>
    </card>
  </div>
</template>

<script>
import { mineHomepageData } from '@/api/statistics/statistics'

export default {

  data() {
    return {
      courseList: [
        {
          id: '1',
          icon: require('@/assets/images/statistics/course_icon1.png'),
          label: '工作站数量',
          value: '--',
          onlineValue: '--'
        },
        {
          id: '2',
          icon: require('@/assets/images/statistics/course_icon2.png'),
          label: '课程数量',
          value: '--',
          onlineValue: '--'
        },
        {
          id: '3',
          icon: require('@/assets/images/statistics/course_icon3.png'),
          label: '题目数量',
          value: '--',
          onlineValue: '--'
        },
        {
          id: '4',
          icon: require('@/assets/images/statistics/course_icon4.png'),
          label: '课件数量',
          value: '--',
          onlineValue: '--'
        }
      ],
      personList: [
        // {
        //   id: "1",
        //   icon: require("@/assets/images/statistics/person_icon1.png"),
        //   label: "在线时长",
        //   value: "--",
        // },
        // {
        //   id: "2",
        //   icon: require("@/assets/images/statistics/person_icon2.png"),
        //   label: "作业批改份数",
        //   value: "--",
        // },
        {
          id: '3',
          icon: require('@/assets/images/statistics/person_icon3.png'),
          label: '试卷批改份数',
          value: '--'
        }
        // {
        //   id: "4",
        //   icon: require("@/assets/images/statistics/person_icon4.png"),
        //   label: "答疑人数",
        //   value: "--",
        // },
        // {
        //   id: "5",
        //   icon: require("@/assets/images/statistics/person_icon5.png"),
        //   label: "申请处理数",
        //   value: "--",
        // },
      ],
      loading: false
    }
  },
  mounted() {
    this.getData()
    this.$store.dispatch('SetKeepTab', [])
  },
  methods: {
    async getData() {
      this.loading = true
      let res
      try {
        res = await mineHomepageData()
      } catch (error) {
        this.loading = false
      }
      this.loading = false
      // 工作站数量
      this.courseList[0].value = res.data.workstationNum ? res.data.workstationNum : 0
      //课程数量
      this.courseList[1].value = res.data.temporaryCourseNum ? res.data.temporaryCourseNum : 0
      this.courseList[1].onlineValue = res.data.courseNum ? res.data.courseNum : 0
      //题目数量
      this.courseList[2].value = res.data.temporaryCourseTopicNum ? res.data.temporaryCourseTopicNum : 0
      this.courseList[2].onlineValue = res.data.courseTopicNum ? res.data.courseTopicNum : 0
      //课件数量
      this.courseList[3].value = res.data.temporaryCourseFileNum ? res.data.temporaryCourseFileNum : 0
      this.courseList[3].onlineValue = res.data.courseFileNum ? res.data.courseFileNum : 0

      this.personList[0].value = res.data.examMarkNum ? res.data.examMarkNum : 0
    },
    toGradeList() {
      this.$router.push({
        path: '/statistics/gradeList'
      })
    },
    toTeachingQualityAnalysis() {
      this.$router.push({
        path: '/statistics/TeachingQualityAnalysis'
      })
    }
  }
}
</script>

<style scoped lang="scss">
.container {
  padding: 31px 39px;
  box-sizing: border-box;

  .title {
    width: 100%;
    font-size: 18px;
    font-family: PingFangSC-Semibold, PingFang SC, sans-serif;
    font-weight: 600;
    color: #333333;
  }

  .teach_statistics {
    width: 100%;
    display: flex;
    margin-top: 32px;

    .teach_item {
      width: 320px;
      height: 120px;
      background: #ffffff;
      border-radius: 32px;
      border: 1px solid #e2e2e2;
      display: flex;
      align-items: center;
      padding-left: 24px;
      box-sizing: border-box;
      cursor: pointer;
      user-select: none;

      &_left {
        width: 76px;
        height: 76px;

        img {
          width: 100%;
          height: 100%;
        }
      }

      &_right {
        margin-left: 24px;

        &_label {
          font-size: 18px;
          font-family: PingFangSC-Semibold, PingFang SC, sans-serif;
          font-weight: 600;
          color: #333333;
        }

        &_btn {
          margin-top: 10px;
          font-size: 12px;
          font-family: PingFangSC-Semibold, PingFang SC, sans-serif;
          font-weight: 600;
        }
      }
    }

    .teach_item:hover {
      box-shadow: 0 0 16px 0 rgba(0, 44, 84, 0.14);
      border: 0;
    }
  }

  .course_statistics {
    display: flex;
    margin-top: 33px;

    .course_item {
      margin-right: 48px;
      width: 176px;
      height: 96px;
      background-size: cover;
      background-repeat: no-repeat;
      display: flex;
      justify-content: center;
      flex-direction: column;
      cursor: pointer;
      user-select: none;

      &_label {
        font-size: 14px;
        font-family: PingFangSC-Medium, PingFang SC, sans-serif;
        font-weight: 500;
        color: #999999;
      }

      &_value {
        font-size: 28px;
        font-family: DINAlternate-Bold, DINAlternate;
        font-weight: bold;
        color: #333333;
      }
    }
  }
}

.color_purole {
  color: #a691f0;
}

.color_blue {
  color: #679ff6;
}

.ml_48 {
  margin-left: 48px;
}

.mt_64 {
  margin-top: 64px;
}

.pd_num {
  padding: 16px 0 0 74px;
  box-sizing: border-box;
}
</style>
